﻿<SettingsFlyout
    x:Class="Fabrikam.Client.SettingsFlyoutItem"
    DataContext="{Binding Source={StaticResource SettingFlyoutItemViewModel}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:conv="using:Fabrikam.Client.Converters"
    xmlns:local="using:Fabrikam.Client"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    HorizontalContentAlignment="Stretch"
    IconSource="Assets/SmallLogo.png"
    Title="{Binding Title}"
    d:DesignWidth="650">

    <SettingsFlyout.Resources>
        <conv:ColorLevelConverter x:Key="ColorLevelConverter" />
        <conv:DateTimeToDateTimeOffsetConverter x:Key="DateTimeToDateTimeOffsetConverter" />
        <conv:StatusConverter x:Key="StatusConverter" />
    </SettingsFlyout.Resources>

    <!-- This StackPanel acts as a root panel for vertical layout of the content sections -->
    <StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >

        <!-- The StackPanel(s) below define individual content sections -->

        <!-- Content Section 1-->
        <StackPanel Style="{StaticResource SettingsFlyoutSectionStyle}" HorizontalAlignment="Stretch">
            <!-- Section 1 header -->
            <TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="Titre" />
            <TextBox Margin="0,7,0,0" Text="{Binding Title, Mode=TwoWay}"  PlaceholderText="Title ..." />
            
            <TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="Customer" />
            <ComboBox ItemsSource="{Binding Customers}" SelectedItem="{Binding CurrentCustomer, Mode=TwoWay}" Margin="0,7,0,0" >
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding FirstName}" />
                            <TextBlock Text="{Binding LastName}" Margin="5,0,0,0" />
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
       
            <TextBlock Text="Opened" Margin="0,0,0,8" Style="{StaticResource TitleTextBlockStyle}" Foreground="Black" />
            <DatePicker Grid.Column="1"  Date="{Binding Opened, Mode=TwoWay, Converter={StaticResource DateTimeToDateTimeOffsetConverter}}"
								HorizontalAlignment="Stretch" VerticalAlignment="Center"   />
            <TextBlock Text="Closed :" Margin="0,0,0,8" Style="{StaticResource TitleTextBlockStyle}"  Foreground="Black" />
            <DatePicker Grid.Column="1" Grid.Row="1" Date="{Binding Closed,  Mode=TwoWay, Converter={StaticResource DateTimeToDateTimeOffsetConverter}}"
								HorizontalAlignment="Stretch" VerticalAlignment="Center"  />

             <!-- Section 1 header -->
            <TextBlock Style="{StaticResource TitleTextBlockStyle}" Text="Description" />
            <TextBox Margin="0,7,0,0" Text="{Binding Description, Mode=TwoWay}" 
                     TextWrapping="Wrap"  PlaceholderText="Description ..."
                     AcceptsReturn="True" Height="200" />
  
            <TextBlock Text="Status" Margin="0,0,0,8" Style="{StaticResource TitleTextBlockStyle}" Foreground="Black" />
            <ListBox Margin="0,0,0,8" ItemsSource="{Binding AvailableStates}" Height="90" 
                     Background="Transparent" 
                     VerticalAlignment="Top"
					 ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch"
					 SelectedItem="{Binding StatusValue, Mode=TwoWay}"
					 ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollMode="Disabled" 
                     ScrollViewer.VerticalScrollMode="Disabled">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" Margin="0" HorizontalAlignment="Stretch" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Image Grid.Column="0" Height="70" VerticalAlignment="Center">
                            <Image.Source>
                                <BitmapImage UriSource="{Binding Converter={StaticResource StatusConverter}}"/>
                            </Image.Source>
                        </Image>
                    </DataTemplate>
                </ListBox.ItemTemplate>

            </ListBox>
        </StackPanel>

        <StackPanel Style="{StaticResource SettingsFlyoutSectionStyle}" HorizontalAlignment="Stretch">
            <StackPanel Margin="0,0,0,0" HorizontalAlignment="Right" Orientation="Horizontal">
                <Button Content="OK" Width="90" Margin="0,0,20,0" Command="{Binding SaveCommand}" Click="OkButton_Click" />
                <Button Content="CANCEL" Width="90" Command="{Binding CancelCommand}" Click="CancelButton_Click"  />
            </StackPanel>
        </StackPanel>
        <!-- Define more Content Sections below as necessary -->

    </StackPanel>
</SettingsFlyout>
